package cn.iocoder.yudao.module.system.controller.app.merchant;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.controller.app.merchant.vo.BusinessBaseApplicationReqVO;
import cn.iocoder.yudao.module.system.controller.app.merchant.vo.BusinessMerchantApplicationVO;
import cn.iocoder.yudao.module.system.service.merchant.MerchantAuthService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * @author 梁富贵
 * @Date 2024/10/18
 **/
@Tag(name = "用户App - 申请成为商家")
@RestController
@RequestMapping("/user/merchant-application")
@Validated
public class AppMerchantApplicationController {
    @Resource
    private MerchantAuthService merchantAuthService;

    @Operation(summary = "申请成为企业商家")
    @PostMapping("/business-application")
    public CommonResult<Boolean> businessMerchantApplication(@ModelAttribute BusinessMerchantApplicationVO businessMerchantApplicationVO) throws IOException {
        return CommonResult.success(merchantAuthService.insertMerchantAuth(businessMerchantApplicationVO,"/user/merchant-application"));
    }

    @Operation(summary = "申请成为个人商家")
    @PostMapping("/individual-application")
    public CommonResult<Boolean> individualMerchantApplication(@ModelAttribute BusinessBaseApplicationReqVO businessMerchantApplicationVO) throws IOException {
        return CommonResult.success(merchantAuthService.insertMerchantAuth(businessMerchantApplicationVO,"/user/merchant-application"));
    }
}
